<?php
  if(cmd("setlevel",50)){
    $userLevelMod=strtolower($msg_args[1]);
    $levelLevelMod=(int)$msg_args[2];
    $levels[$userLevelMod]=$levelLevelMod;
    msg($msg_args[1]." now has an access level of ".$levels[$userLevelMod]);
    updateAccess();
  }
  if(cmd("ignore",50)){
    $userLevelMod=strtolower($msg_args[1]);
    $oldlevels[$userLevelMod] = 0;
    if (array_key_exists($userLevelMod, $levels))
    	$oldlevels[$userLevelMod] = intval($levels[$userLevelMod]);
    $levels[$userLevelMod] = -1;
    msg($msg_args[1]." has been ignored [access level -1]");
    updateAccess();
  }

  if(cmd("unignore",50)){
    $userLevelMod=strtolower($msg_args[1]);
    $levels[$userLevelMod]=$oldlevels[$userLevelMod];
    msg($msg_args[1]." now has an access level of ".$levels[$userLevelMod]);
    updateAccess();
  }

  if(cmd("level")){
    $userLevel=strtolower($msg_args[1]);
    if(empty($userLevel)){
      $userLevel=strtolower($source_nick);
      if(!$levels[$userLevel]){
        $userLevel=strtolower($source_host);
      }
      echo $userLevel;
      if($levels[$userLevel]){
        msg("$source_nick: your access level is ".$levels[$userLevel]);
      } else {
        msg("$source_nick: your access level hasn't been set, so it defaults to 0");
      }
    } else {
      if($levels[$userLevel]){
        msg($msg_args[1]."'s access level is ".$levels[$userLevel]);
      } else {
        msg($msg_args[1]."'s access level hasn't been set, so it defaults to 0");
      }
    }
  }

  if(cmd("levels")){
    $levelStr="";
    foreach($levels as $user=>$level){
      if ($level != 0)
				$levelStr.="$user: $level, ";
    }
    $levelStr=trim($levelStr,", ");
    if(empty($levelStr)){
      $levelStr="No set access levels... This shouldn't happen people...";
    }
    msg($levelStr);

  }
  
  //*/
?>